package _test;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Pictest extends Component implements ActionListener {

	private ImageIcon icon;

	public static void main(String[] args) {
		new Pictest();
	}
	
	public Pictest() {
		JFrame f = new JFrame();
		JPanel bottom = new JPanel();
		JPanel buttonpanel = new JPanel();
		JButton b = new JButton("refresh");
		b.addActionListener(this);
		buttonpanel.add(b);
		bottom.add(this);
		bottom.add(buttonpanel);
		f.setContentPane(bottom);

		icon = new ImageIcon("data/misc/test.png");
		this.setPreferredSize(new Dimension(400, 400));
		f.pack();
		f.setVisible(true);
	}
	
	private boolean first=true;
	@Override
	public void paint(Graphics g) {
		g.drawImage(icon.getImage(), 100, 100, null);
		g.drawImage(icon.getImage(), 95, 90, null);
		
		if (first) {
			g.setColor(Color.GREEN);
			g.fillOval(103, 103, 5, 5);
			first=false;
		}
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		this.repaint();
	}
}
